package com.szcinda.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface LineRepository extends JpaRepository<Line, String>, JpaSpecificationExecutor<Line> {
    Line findByOriginPlaceAndDestPlace(String originPlace, String destPlace);
    Line findFirstById(String id);

    @Query("select l from Line l where l.originPlace like CONCAT('%',?1,'%') or l.destPlace like CONCAT('%',?1,'%')")
    List<Line> search(@Param("text") String text);
}
